<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>django 1 django和mysql | Jin Tian</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  <meta name="keywords" content="Django" />
  
  
  
  
  <meta name="description" content="这个post是讲述django和mysql的故事，记录django常用命令以及mysql的python接口安装方法，环境为python3.6。">
<meta name="keywords" content="Django">
<meta property="og:type" content="article">
<meta property="og:title" content="Django 1 Django和mysql">
<meta property="og:url" content="http://yoursite.com/2017/01/12/Django-1-Django上手教程/index.html">
<meta property="og:site_name" content="Jin Tian">
<meta property="og:description" content="这个post是讲述django和mysql的故事，记录django常用命令以及mysql的python接口安装方法，环境为python3.6。">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2017-01-26T10:44:52.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Django 1 Django和mysql">
<meta name="twitter:description" content="这个post是讲述django和mysql的故事，记录django常用命令以及mysql的python接口安装方法，环境为python3.6。">
  
    <link rel="alternate" href="/atom.xml" title="Jin Tian" type="application/atom+xml">
  

  

  <link rel="icon" href="/css/images/mylogo.jpg">
  <link rel="apple-touch-icon" href="/css/images/mylogo.jpg">
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link href="https://fonts.googleapis.com/css?family=Open+Sans|Montserrat:700" rel="stylesheet" type="text/css">
  <link href="https://fonts.googleapis.com/css?family=Roboto:400,300,300italic,400italic" rel="stylesheet" type="text/css">
  <link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
  <style type="text/css">
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/9749f0/00000000000000000001008f/27/l?subset_id=2&fvd=n5) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/90cf9f/000000000000000000010091/27/l?subset_id=2&fvd=n7) format("woff2");font-weight:500;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/8a5494/000000000000000000013365/27/l?subset_id=2&fvd=n4) format("woff2");font-weight:lighter;font-style:normal;}
    @font-face{font-family:futura-pt;src:url(https://use.typekit.net/af/d337d8/000000000000000000010095/27/l?subset_id=2&fvd=i4) format("woff2");font-weight:400;font-style:italic;}</style>
  <link rel="stylesheet" href="/css/style.css">

  <script src="/js/jquery-3.1.1.min.js"></script>
  <script src="/js/bootstrap.js"></script>

  <!-- Bootstrap core CSS -->
  <link rel="stylesheet" href="/css/bootstrap.css" >

  
    <link rel="stylesheet" href="/css/dialog.css">
  

  

  
    <link rel="stylesheet" href="/css/header-post.css" >
  

  
  
  
    <link rel="stylesheet" href="/css/vdonate.css" >
  

</head>



  <body data-spy="scroll" data-target="#toc" data-offset="50">


  
  <div id="container">
    <div id="wrap">
      
        <header>

    <div id="allheader" class="navbar navbar-default navbar-static-top" role="navigation">
        <div class="navbar-inner">
          
          <div class="container"> 
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>

            
              <a class="brand" style="
                 border-width: 0px;  margin-top: 0px;"  
                href="#" data-toggle="modal" data-target="#myModal" >
                  <img width="124px" height="124px" alt="Hike News" src="/css/images/mylogo.jpg">
              </a>
            
            
            <div class="navbar-collapse collapse">
              <ul class="hnav navbar-nav">
                
                  <li> <a class="main-nav-link" href="/">首页</a> </li>
                
                  <li> <a class="main-nav-link" href="/archives">归档</a> </li>
                
                  <li> <a class="main-nav-link" href="/categories">分类</a> </li>
                
                  <li> <a class="main-nav-link" href="/tags">标签</a> </li>
                
                  <li> <a class="main-nav-link" href="/about">关于</a> </li>
                
                  <li> <a class="main-nav-link" href="http://luoli-luoli.com/chat">chat</a> </li>
                
                  <li><div id="search-form-wrap">

    <form class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="" />
        <button type="submit" class="search-form-submit"></button>
    </form>
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="请输入关键词..." />
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(无标题)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/js/insight.js"></script>

</div></li>
            </div>
          </div>
                
      </div>
    </div>

</header>



      
            
      <div id="content" class="outer">
        
          <section id="main" style="float:none;"><article id="post-Django-1-Django上手教程" style="width: 75%; float:left;" class="article article-type-post" itemscope itemprop="blogPost" >
  <div id="articleInner" class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="thumb" class="article-title" itemprop="name">
      Django 1 Django和mysql
    </h1>
  

      </header>
    
    <div class="article-meta">
      
	<a href="/2017/01/12/Django-1-Django上手教程/" class="article-date">
	  <time datetime="2017-01-12T12:31:45.000Z" itemprop="datePublished">2017-01-12</time>
	</a>

      
      
	<a class="article-views">
	<span id="busuanzi_container_page_pv">
		阅读量<span id="busuanzi_value_page_pv"></span>
	</span>
	</a>

    </div>
    <div class="article-entry" itemprop="articleBody">
      
        <p>这个post是讲述django和mysql的故事，记录django常用命令以及mysql的python接口安装方法，环境为python3.6。<br><a id="more"></a></p>
<blockquote>
<p>本文由作者金天原创，欢迎大家转载，不过请保留这段版权信息，多谢合作，如对本文有任何问题欢迎联系作者: jintianiloveu。</p>
</blockquote>
<h3 id="Django大法"><a href="#Django大法" class="headerlink" title="Django大法"></a>Django大法</h3><p>作为一位极客，不会点服务端还真不行，现在什么都离不开云啊，最近一直想建站，app接口也要用到云，本来打算用java，可是想了一下java即使使用框架访问数据库的效率还是有点低，而我呢，python玩得这么6，人生苦短啊为何不用python，反正都是事先一样的东西，我们做的也不是淘宝天猫，不需要考虑太多并发的东西，因此从某种意义上来讲，使用django是一个非常不错的选择。好了闲话不多说，这是一个<strong>django之歌</strong>的系列，既然是歌那就得分乐章，不分逻辑了。</p>
<h3 id="Django命令"><a href="#Django命令" class="headerlink" title="Django命令"></a>Django命令</h3><p><strong> [UPDATE] 2017-01-26 </strong><br><figure class="highlight stylus"><table><tr><td class="code"><pre><div class="line">python3 manage<span class="selector-class">.py</span> createsuperuser</div></pre></td></tr></table></figure></p>
<p>这个命领用来创建一个django的后台管理员用户名和密码。</p>
<p>Django的安装就不多说了，安装好python，比如mac下<code>brew install pyton3</code>就ok了，再次必须说明一下，我不太喜欢过时的东西，但是太新意味着踩坑，所以大家要做好踩坑的准备。Django安装好之后就可以直接用了，这里我收集一下django入门会用到的命令吧：<br><figure class="highlight stylus"><table><tr><td class="code"><pre><div class="line">django-admin startproject deepx</div><div class="line">python3 manage<span class="selector-class">.py</span> startapp <span class="selector-tag">article</span></div><div class="line">python3 manage<span class="selector-class">.py</span> runserver</div></pre></td></tr></table></figure></p>
<p>第一个命令是新建项目，第二个新建一个app，这里一个app其实就是项目中的一个功能模块，在我看来。<br>新建好的django一般是这样的工程目录：<br><figure class="highlight stylus"><table><tr><td class="code"><pre><div class="line">.</div><div class="line">├── <span class="selector-tag">article</span></div><div class="line">│   ├── __init__<span class="selector-class">.py</span></div><div class="line">│   ├── __pycache__</div><div class="line">│   │   └── __init__<span class="selector-class">.cpython-36</span><span class="selector-class">.pyc</span></div><div class="line">│   ├── admin<span class="selector-class">.py</span></div><div class="line">│   ├── apps<span class="selector-class">.py</span></div><div class="line">│   ├── migrations</div><div class="line">│   │   └── __init__<span class="selector-class">.py</span></div><div class="line">│   ├── models<span class="selector-class">.py</span></div><div class="line">│   ├── tests<span class="selector-class">.py</span></div><div class="line">│   └── views<span class="selector-class">.py</span></div><div class="line">├── lewisblog</div><div class="line">│   ├── __init__<span class="selector-class">.py</span></div><div class="line">│   ├── __pycache__</div><div class="line">│   │   ├── __init__<span class="selector-class">.cpython-36</span><span class="selector-class">.pyc</span></div><div class="line">│   │   └── settings<span class="selector-class">.cpython-36</span><span class="selector-class">.pyc</span></div><div class="line">│   ├── settings<span class="selector-class">.py</span></div><div class="line">│   ├── urls<span class="selector-class">.py</span></div><div class="line">│   └── wsgi<span class="selector-class">.py</span></div><div class="line">└── manage.py</div></pre></td></tr></table></figure></p>
<p>这里article就是app，lewisblog是整个工程的名字。</p>
<h3 id="Django和mysql"><a href="#Django和mysql" class="headerlink" title="Django和mysql"></a>Django和mysql</h3><p><strong>UPDATE</strong><br>这里增加一下，很多人说python3.6 安装mysql报错，解决方法是python3安装<strong>mysqlclient</strong>，网上很多方法都是过时，其他mysql的驱动并不适用python3，大家注意了啊！<br>可以说这是一对好拍档，很多人说django自带的sqlite就很不错啊，使得sqlite很方便不用安装不用配置，数据库文件就在工程的目录下，访问简单快捷，但是呢，sqlite并太轻了，我们还是使用mysql吧，毕竟比较流行，而且一些语句也是我们常用的语句，因此可以说mysql是非常合适不过的啦。在配置mysql的时候要在上面的<code>settings.py</code>中设置：<br><figure class="highlight ebnf"><table><tr><td class="code"><pre><div class="line"><span class="attribute">DATABASES</span> = &#123;</div><div class="line">    <span class="string">'default'</span>: &#123;</div><div class="line">        <span class="string">'ENGINE'</span>: <span class="string">'django.db.backends.mysql'</span>,</div><div class="line">        <span class="string">'NAME'</span>: <span class="string">'lewisblog'</span>,</div><div class="line">        <span class="string">'USER'</span>: <span class="string">'root'</span>,</div><div class="line">        <span class="string">'PASSWORD'</span>: <span class="string">'root'</span>,</div><div class="line">        <span class="string">'HOST'</span>: <span class="string">'127.0.0.1'</span>,</div><div class="line">        <span class="string">'PORT'</span>: <span class="string">'3306'</span>,</div><div class="line">    &#125;</div></pre></td></tr></table></figure></p>
<p>ok,在这里我们就设置好了数据库引擎以及数据库的名字和密码之类的东西，当然要想链接上数据库还得再mysql中新建则个数据库，数据库名字随便取罗。然后我们要干啥？对了这个settings，在你新建了一个app之后记得在这里登记一下，这里可以控制是哪些app有效。</p>
<h3 id="Django和Model"><a href="#Django和Model" class="headerlink" title="Django和Model"></a>Django和Model</h3><p>很多人都说DJango是一个template，为什么这么说，思考一下，很多其他库做后台操作数据库都免不了要写一些数据库查询语句，增删改查都要连接数据库查询有没有然后增删改，但是这样做的效率其实是非常低的。很多不必要的操作都是在这里产生的。<br>而Django在这个地方就不同，它自己实现一个很强大的基类，就是model，这就是一个数据库模型，在model里面你可以找到数据库里面的各种数据类型，甚至在时间的操作上比数据库还简单。比如我们要写一个article的表，我们不用再数据库里面建了，建好了然后在写一个数据类，这在java里面你就得干这个脏活，但是在django里你就不需要重复无意义的事情了，<strong>你只需要建一个model</strong>，然后migrate一下，你就可以在mysql中看到你新建的表了。怎么样方便吧，哎写了这么多肚子有饿了。看来明天得好好吃一顿了。<br>贴一个model新建的类的代码：(在上面的app下面的models.py中)<br><figure class="highlight python"><table><tr><td class="code"><pre><div class="line"><span class="keyword">from</span> django.db <span class="keyword">import</span> models</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment"># Create your models here.</span></div><div class="line"><span class="class"><span class="keyword">class</span> <span class="title">Article</span><span class="params">(models.Model)</span>:</span></div><div class="line">    title = models.CharField(max_length=<span class="number">100</span>, blank=<span class="keyword">True</span>)</div><div class="line">    category = models.CharField(max_length=<span class="number">50</span>, blank=<span class="keyword">True</span>)</div><div class="line">    author = models.CharField(max_length=<span class="number">50</span>, blank=<span class="keyword">True</span>)</div><div class="line">    date_time = models.DateTimeField(auto_now_add=<span class="keyword">True</span>)</div><div class="line">    content = models.TextField(blank=<span class="keyword">True</span>, null=<span class="keyword">True</span>)</div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__unicode__</span><span class="params">(self)</span>:</span></div><div class="line">        <span class="keyword">return</span> self.title</div><div class="line"></div><div class="line">    <span class="class"><span class="keyword">class</span> <span class="title">Meta</span>:</span></div><div class="line">        ordering = [<span class="string">'-date_time'</span>]</div></pre></td></tr></table></figure></p>
<p>看看，所见即所得，你一旦实现了这个model之后你就不用管mysql了，以后插入数据什么的只需要实现这个类就行了，简直是方便的有点蛋疼啊！<br>新建了这个model之后，你要把这个应用到mysql需要下面两条啊语句：<br><figure class="highlight vim"><table><tr><td class="code"><pre><div class="line"><span class="keyword">python3</span> manage.<span class="keyword">py</span> makemigrations</div><div class="line"><span class="keyword">python3</span> manage,<span class="keyword">py</span> migrate</div></pre></td></tr></table></figure></p>
<p>第一条意思是我把model在本地生成一个migrations文件夹，里面要记录你对数据的操作，而第二个命令就是你对这个操作施加到数据库中。两条命令按顺序执行才能deploy到数据库里面，这时候打开mysql就可以看到我们的表了：<br><figure class="highlight asciidoc"><table><tr><td class="code"><pre><div class="line">mysql&gt; USE lewisblog;</div><div class="line">Reading table information for completion of table and column names</div><div class="line">You can turn off this feature to get a quicker startup with -A</div><div class="line"></div><div class="line">Database changed</div><div class="line"><span class="section">mysql&gt; SHOW TABLES;</span></div><div class="line">+----------------------------+</div><div class="line"><span class="section">| Tables_in_lewisblog        |</span></div><div class="line">+----------------------------+</div><div class="line">| article<span class="emphasis">_article            |</span></div><div class="line">| auth_group                 |</div><div class="line">| auth<span class="emphasis">_group_</span>permissions     |</div><div class="line">| auth<span class="emphasis">_permission            |</span></div><div class="line">| auth_user                  |</div><div class="line">| auth<span class="emphasis">_user_</span>groups           |</div><div class="line">| auth<span class="emphasis">_user_</span>user<span class="emphasis">_permissions |</span></div><div class="line">| django_admin<span class="emphasis">_log           |</span></div><div class="line">| django_content<span class="emphasis">_type        |</span></div><div class="line">| django_migrations          |</div><div class="line"><span class="section">| django_session             |</span></div><div class="line">+----------------------------+</div><div class="line">11 rows in set (0.00 sec)</div></pre></td></tr></table></figure></p>
<p>看到没，我们的模型已经转换成表了。6不6！！！</p>
<h3 id="Django的mysql-shell"><a href="#Django的mysql-shell" class="headerlink" title="Django的mysql shell"></a>Django的mysql shell</h3><p>其实Django内置了一个shell，在这个shell里面你可以模拟mysql对数据库进行增删改查，但是呢，要进入这个shell还是得默默的进入，不要让任何人知道：<br><figure class="highlight vim"><table><tr><td class="code"><pre><div class="line"><span class="keyword">python3</span> manage.<span class="keyword">py</span> <span class="keyword">shell</span></div></pre></td></tr></table></figure></p>
<p>进入shell，这是一个神奇的地方，我们执行以下这个命令：<br><figure class="highlight stylus"><table><tr><td class="code"><pre><div class="line">&gt;&gt;&gt; from <span class="selector-tag">article</span><span class="selector-class">.models</span> import Article</div><div class="line">&gt;&gt;&gt; Article<span class="selector-class">.objects</span><span class="selector-class">.create</span>(title = <span class="string">'hello world.'</span>, category = <span class="string">'django'</span>, author = <span class="string">'Lewis Jin'</span>, <span class="attribute">content</span> = <span class="string">'Today I leared Django and it is very nice!'</span>)                                                                                         </div><div class="line">&lt;Article: Article object&gt;</div></pre></td></tr></table></figure></p>
<p>接着你甚至不用migrate就可以直接在mysql中查看到我们已经成功地添加了一条记录在数据库中！你就说6不6！！<br><figure class="highlight asciidoc"><table><tr><td class="code"><pre><div class="line"><span class="section">mysql&gt; mysql&gt; SELECT * FROM article_article;</span></div><div class="line">+----+--------------+----------+-----------+----------------------------+--------------------------------------------+</div><div class="line"><span class="section">| id | title        | category | author    | date_time                  | content                                    |</span></div><div class="line">+----+--------------+----------+-----------+----------------------------+--------------------------------------------+</div><div class="line"><span class="section">|  1 | hello world. | django   | Lewis Jin | 2017-01-12 13:25:13.273888 | Today I leared Django and it is very nice! |</span></div><div class="line">+----+--------------+----------+-----------+----------------------------+--------------------------------------------+</div></pre></td></tr></table></figure></p>
<p>这是增，改和删也很简单：<br><figure class="highlight stylus"><table><tr><td class="code"><pre><div class="line">&gt;&gt;&gt; <span class="selector-tag">a</span> = Article<span class="selector-class">.objects</span><span class="selector-class">.get</span>(id=<span class="number">1</span>)</div><div class="line">&gt;&gt;&gt; <span class="selector-tag">a</span><span class="selector-class">.title</span></div><div class="line"><span class="string">'hello world.'</span></div><div class="line">&gt;&gt;&gt; <span class="selector-tag">a</span><span class="selector-class">.title</span> = <span class="string">'Hello World'</span></div><div class="line">&gt;&gt;&gt; <span class="selector-tag">a</span><span class="selector-class">.title</span></div><div class="line"><span class="string">'Hello World'</span></div><div class="line">&gt;&gt;&gt; <span class="selector-tag">a</span>.delete()</div></pre></td></tr></table></figure></p>
<h3 id="本篇章结语"><a href="#本篇章结语" class="headerlink" title="本篇章结语"></a>本篇章结语</h3><p>基本上看完这些就可以入门了，接下来我们更加深入的剖析django，我们要充分利用这个利器，来实现我们想要的web程序，让云变的触手可及！！</p>

      
    </div>
    <footer class="article-footer">
      
        <div id="donation_div"></div>

<script src="/js/vdonate.js"></script>
<script>
var a = new Donate({
  title: '骚年，加个好友打赏一下啊，现在连泡面都吃不起了啊', // 可选参数，打赏标题
  btnText: '打赏支持', // 可选参数，打赏按钮文字
  el: document.getElementById('donation_div'),
  wechatImage: 'https://i.loli.net/2017/09/27/59cb048ba6838.jpeg',
  alipayImage: 'https://i.loli.net/2017/09/27/59cb049cd0951.jpeg'
});
</script>
      
      
        
	<div id="comment">
		<!-- 来必力City版安装代码 -->
		<div id="lv-container" data-id="city" data-uid="MTAyMC8zMDA5MC82NjQ1">
		<script type="text/javascript">
		   (function(d, s) {
		       var j, e = d.getElementsByTagName(s)[0];

		       if (typeof LivereTower === 'function') { return; }

		       j = d.createElement(s);
		       j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
		       j.async = true;

		       e.parentNode.insertBefore(j, e);
		   })(document, 'script');
		</script>
		<noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
		</div>
		<!-- City版安装代码已完成 -->
	</div>



      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Django/">Django</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2017/01/15/Django-2-MySQL-and-Blog/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">上一篇</strong>
      <div class="article-nav-title">
        
          Django 2 MySQL and Blog
        
      </div>
    </a>
  
  
    <a href="/2017/01/02/Mac下安装和使用postgreSQL/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">下一篇</strong>
      <div class="article-nav-title">Mac下安装和使用postgreSQL</div>
    </a>
  
</nav>

  
</article>

<!-- Table of Contents -->

  <aside id="toc-sidebar">
    <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录</strong>
    
        <ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#Django大法"><span class="nav-number">1.</span> <span class="nav-text">Django大法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Django命令"><span class="nav-number">2.</span> <span class="nav-text">Django命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Django和mysql"><span class="nav-number">3.</span> <span class="nav-text">Django和mysql</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Django和Model"><span class="nav-number">4.</span> <span class="nav-text">Django和Model</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Django的mysql-shell"><span class="nav-number">5.</span> <span class="nav-text">Django的mysql shell</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#本篇章结语"><span class="nav-number">6.</span> <span class="nav-text">本篇章结语</span></a></li></ol>
    
    </div>
  </aside>
</section>
        
      </div>
      
      <footer id="footer">
  

  <div class="container">
      	<div class="row">
	      <p> Powered by <a href="http://www.luoli-luoli.com/" target="_blank">萝莉萝莉</a> and <a href="http://www.luoli-luoli.com/sia" target="_blank">Sia</a> </p>
	      <p id="copyRightEn">Copyright &copy; 2017 - 2018 Jin Tian All Rights Reserved.</p>
	      
	      
    		<p class="busuanzi_uv">
				访客数 : <span id="busuanzi_value_site_uv"></span> |  
				访问量 : <span id="busuanzi_value_site_pv"></span>
		    </p>
  		   
		</div>

		
  </div>
</footer>


<!-- min height -->

<script>
    var wrapdiv = document.getElementById("wrap");
    var contentdiv = document.getElementById("content");
    var allheader = document.getElementById("allheader");

    wrapdiv.style.minHeight = document.body.offsetHeight + "px";
    if (allheader != null) {
      contentdiv.style.minHeight = document.body.offsetHeight - allheader.offsetHeight - document.getElementById("footer").offsetHeight + "px";
    } else {
      contentdiv.style.minHeight = document.body.offsetHeight - document.getElementById("footer").offsetHeight + "px";
    }
</script>
    </div>
    <!-- <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
    <a href="/categories" class="mobile-nav-link">Categories</a>
  
    <a href="/tags" class="mobile-nav-link">Tags</a>
  
    <a href="/about" class="mobile-nav-link">About</a>
  
    <a href="http://luoli-luoli.com/chat" class="mobile-nav-link">Chat</a>
  
</nav> -->
    

<!-- mathjax config similar to math.stackexchange -->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
      tex2jax: {
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
    });
</script>

<script type="text/x-mathjax-config">
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for(i=0; i < all.length; i += 1) {
            all[i].SourceElement().parentNode.className += ' has-jax';
        }
    });
</script>

<script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/scripts.js"></script>




  <script src="/js/dialog.js"></script>








	<div style="display: none;">
    <script src="https://s95.cnzz.com/z_stat.php?id=1260716016&web_id=1260716016" language="JavaScript"></script>
  </div>



	<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
	</script>






  </div>

  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h2 class="modal-title" id="myModalLabel">设置</h2>
      </div>
      <hr style="margin-top:0px; margin-bottom:0px; width:80%; border-top: 3px solid #000;">
      <hr style="margin-top:2px; margin-bottom:0px; width:80%; border-top: 1px solid #000;">


      <div class="modal-body">
          <div style="margin:6px;">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne" onclick="javascript:setFontSize();" aria-expanded="true" aria-controls="collapseOne">
              正文字号大小
            </a>
          </div>
          <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
          <div class="panel-body">
            您已调整页面字体大小
          </div>
        </div>
      


          <div style="margin:6px;">
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" onclick="javascript:setBackground();" aria-expanded="true" aria-controls="collapseTwo">
              夜间护眼模式
            </a>
        </div>
          <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
          <div class="panel-body">
            夜间模式已经开启，再次单击按钮即可关闭 
          </div>
        </div>

        <div>
            <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="true" aria-controls="collapseThree">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;关 于&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
        </div>
         <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
          <div class="panel-body">
            Jin Tian
          </div>
          <div class="panel-body">
            Copyright © 2018 Jintian All Rights Reserved.
          </div>
        </div>
      </div>


      <hr style="margin-top:0px; margin-bottom:0px; width:80%; border-top: 1px solid #000;">
      <hr style="margin-top:2px; margin-bottom:0px; width:80%; border-top: 3px solid #000;">
      <div class="modal-footer">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
      </div>
    </div>
  </div>
</div>
  
  <a id="rocket" href="#top" class=""></a>
  <script type="text/javascript" src="/js/totop.js?v=1.0.0" async=""></script>
  
    <a id="menu-switch"><i class="fa fa-bars fa-lg"></i></a>
  
</body>
</html>